//
//  NSString+Util.h
//  NewHelome
//
//  Created by kele on 14-9-17.
//  Copyright (c) 2014年 jetxiao. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <ifaddrs.h>
#import <arpa/inet.h>
#import <net/if.h>

#define IP_ADDR_IPv4    @"ipv4"
#define IP_ADDR_IPv6    @"ipv6"
#define IOS_CELLULAR    @"pdp_ip0"
#define IOS_WIFI        @"en0"
#define IOS_VPN         @"utun0"

@interface NSString (Util)

@property (readonly) BOOL hasValue;// 判断String是否有值
@property (readonly) BOOL isPhone;
@property (readonly) BOOL isChineseIDCard;// 判断String是否是身份证号

- (BOOL)containsChineseCharacters;

- (NSUInteger)wordCount;

- (NSString *)subCharacterFromIndex:(NSUInteger)aIndex;

+ (BOOL) isBlankString:(NSString *)string;

+ (NSString *)converNumber:(NSNumber *)aNumber,...;

+ (NSString *)backDefaultIfNilWithString:(NSString *)string defaultString:(NSString *)defaultString;


- (NSString *)trim;

- (NSString *)urlEncode;

- (NSString *)urlDecode;

- (NSString *)replaceBlank;
- (NSString *)replaceNull;

- (NSString *)md5;
- (NSString *)sha1;

- (BOOL)isVaildTel;

- (BOOL)isVaildMail;

- (NSString *)filterNonNumber;

- (CGSize)sizeWithFont:(UIFont *)font maxW:(CGFloat)maxW;

- (CGSize)sizeWithFont:(UIFont *)font;

- (void)phoneCall;

- (NSString *)parseDateFormatWithFormat:(NSString *)converFormat;
+ (NSString *)parseDateFormatWithDate:(NSDate *)date converToFormat:(NSString *)converFormat;
+ (NSString *)parseDateSiceNowWithTimerInterval:(NSTimeInterval)timerInterval;
+ (NSString *)parseDateSiceNowWeekWithTimerInterval:(NSTimeInterval)timerInterval;

+ (NSString *)featureWeekdayWithDate:(NSDate *)endDate;
+ (NSInteger)daysFromDate:(NSDate *)startDate toDate:(NSDate *)endDate;
+ (NSInteger)getNowWeekday;

+ (NSString *)parseDateFormatWithTimeInterval:(NSTimeInterval)interval converFormat:(NSString *)converFormat;

+ (NSString *)filterSpecialCharWithString:(NSString *)string;

+ (NSString *)uuidString;

+ (BOOL)judgePassWordLegal:(NSString *)pass;

//判断是否为整形
+ (BOOL)isPureInt:(NSString *)string;

/**
 数字三位分隔
 */
+ (NSString *)changePayMoneyString:(NSString *)payMoneyString;

/** 金额分隔 */
+ (NSString *)moenyAndPoint:(NSString *)string;

/**
 金额分隔
 */
+ (NSString*)strmethodComma:(NSString*)string;

/** 判断汉字字数 */
+ (NSString *)filterCharactor:(NSString *)string withRegex:(NSString *)regexStr;

/** 转换时间戳 */
+ (NSString *)dateChangeToTimeString;

/** 获取当前时间 */
+ (NSString *)getCurrentTimes:(NSString *)dateFormat;

/** 时间转时间戳 */
+ (NSTimeInterval)dateChangeToTimerInterval:(NSString *)timerStr;

/** 字符串转 */
- (NSString *)stringAndDateChange:(NSString *)timeStr dateFormat:(NSString *)dateFormat;

/** 截取HTML */
- (NSArray *)componentsSeparatedFromString:(NSString *)fromString toString:(NSString *)toString;

/** 每个几个字符插入空格 */
- (NSString *)dealWithString:(NSString *)number;

/** 获取指定日期是星期几 */
//+ (id)geteekDayWithDate:(NSDate *)date;
/** 获取当前月所以天数是星期几 */
+ (NSArray *)getAllDaysWithCalender;
/** 获取当前月总天数 */
+ (NSInteger)getNumberOfDaysInMonth;

/**
 获取验证码的签名

 @param mobile 手机号
 @param type 短信类型
 @param nonceStr 随机字符串
 @param timestamp 当前13位时间戳
 */
+ (NSString *)messageCaptchaSign:(NSString *)mobile type:(NSString *)type nonceStr:(NSString *)nonceStr timestamp:(NSString *)timestamp;


/**
 文章详情展示时间

 @param createTimeString 13位时间戳
 @return 规则时间
 */
+ (NSString *)updateTimeForRow:(NSString *)createTimeString;

+ (BOOL)verifyIDCardNumber:(NSString *)value; //验证身份证

/** 获取ip地址 */
+ (NSString *)getIPAddress:(BOOL)preferIPv4;
+ (NSDictionary *)getIPAddresses;
+ (BOOL)isValidatIP:(NSString *)ipAddress;

/** 隐藏手机号中四位 */
- (NSString *)changePhone;
@end
